Developer Documentation
PATHJava Developer Documentation > Mac OS Runtime for Java > JManager > Programming With JManager


Abstract Window Toolkit Control Functions

Every Java program that needs access to the Abstract Window Toolkit (AWT) must have an AWT context associated with it. This AWT context supplies an execution environment for the Java program and an associated thread group. The following functions let you create or remove an AWT context or manipulate elements associated with the context.


JMNewAWTContext

Creates an AWT context.

OSStatus JMNewAWTContext (
                     JMAWTContextRef* context,
                     JMSessionRef session,
                     const JMAWTContextCallbacks* callbacks,
                     JMClientData data);
context
A pointer to the AWT context. On return, this parameter is the new AWT context.
session
The session in which you want to create the AWT context.
callbacks
A pointer to the context's callbacks. See AWT Context Callbacks Structure for more information.
data
Any optional client-specific data.
function result
A result code; see JManager Result Codes.

SEE ALSO

Creating an AWT Context.

The JMNewAWTContextInPage function.

The JMDisposeAWTContext function.


JMDisposeAWTContext

Removes an AWT context.

OSStatus JMDisposeAWTContext (JMAWTContextRef context);
context
The AWT context you want to remove.
function result
A result code; see JManager Result Codes.

DISCUSSION

A successful call to the JMDisposeAWTContext function also removes any frames associated with the AWT context.

SEE ALSO

Creating an AWT Context.

The JMNewAWTContext function.


JMGetAWTContextData

Receives client-specific data associated with an AWT context.

OSStatus JMGetAWTContextData (
                     JMAWTContextRef context,
                     JMClientData* data);
context
The AWT context whose data you want to receive.
data
A pointer to the client-specific data. On return, this parameter points to the client-specific data.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMSetAWTContextData function.

JMSetAWTContextData

Assigns client-specific data to an AWT context.

OSStatus JMSetAWTContextData (
                     JMAWTContextRef context,
                     JMClientData data);
context
The AWT context whose client-specific data you want to change.
data
The new value of the client-specific data.
function result
A result code; see JManager Result Codes.

SEE ALSO

The JMGetAWTContextData function
.

JMCountAWTContextFrames

Counts the number of frames associated with an AWT context.

OSStatus JMCountAWTContextFrames (
                     JMAWTContextRef context,
                     UInt32* frameCount);
context
The AWT context whose frames are being counted.
frameCount
A pointer to the frame count. On return, this parameter holds the number of allocated frames associated with the context. (This value may be 0.)
function result
A result code; see JManager Result Codes.

DISCUSSION

After determining the number of frames, you can then access an individual frame by calling The JMGetAWTContextFrame function.


JMGetAWTContextFrame

Gets a particular frame associated with an AWT context.

OSStatus JMGetAWTContextFrame (
                     JMAWTContextRef context,
                     UInt32 frameIndex,
                     JMFrameRef* frame);
context
The AWT context that contains the frame.
frameIndex
The index number of the frame.
frame
A pointer to the frame. On return, this parameter holds the frame with index frameIndex .
function result
A result code; see JManager Result Codes.

DISCUSSION

The index numbers for frames range from 0 to frameCount -1 (as determined by the JMCountAWTContextFrames function JMCountAWTContextFrames), with the most recently added frame having the highest number. The index number of a particular frame is not necessarily constant; removing or adding frames can cause the index number to change.


JMMenuSelected

Dispatch a menu event to an AWT context.

OSStatus JMMenuSelected (
                     JMAWTContextRef context,
                     MenuHandle hMenu,
                     short menuItem);
context
The AWT context that owns the menu.
hMenu
The menu handle that was selected.
menuItem
The item that was selected.
function result
A result code; see JManager Result Codes.

DISCUSSION

You can use the Mac OS Toolbox function GetMenuHandle to get the appropriate value of the hMenu parameter to pass.


JMMenuSelectedWithModifiers

Dispatch a menu event to an AWT context.

OSStatus JMMenuSelectedWithModifiers(
                     JMAWTContextRef context,
                     MenuHandle hMenu,
                     short menuItem,
                     short modifiers);
context
The AWT context that owns the menu.
hMenu
The menu handle that was selected.
menuItem
The item that was selected.
modifiers
Additional modifiers that you can get from the Mac OS event record.
function result
A result code; see JManager Result Codes.

DISCUSSION

You can use the Mac OS Toolbox function GetMenuHandle to get the appropriate value of the hMenu parameter to pass.


JMExecJNIMethodInContext

Executes a nonstatic Java method in a given AWT context thread using the Java Native Interface (JNI).

OSStatus JMExecJNIMethodInContext (
                     JMAWTContextRef context,
                     JNIEnv* env,
                     jobject objref,
                     jmethodID methodID,
                     UInt32 argCount,
                     jvalue args[]);
context
The AWT context in whose thread you want the method to execute.
env
A pointer to the current JNIEnv data structure.
objref
A pointer to the Java object that contains the method you want to call.
methodID
The ID of the method.
argCount
The number of arguments in the args[] array, which should match the number of arguments expected by the method.
args[]
The argument list.
function result
A result code; see JManager Result Codes.

DISCUSSION

Before calling this function, you must call the JMGetCurrentEnv function JMGetCurrentEnv to get the JNIEnv pointer.

If you want to execute a static Java method (that is, one that is not local to an object) using the JNI, you must call the JMExecJNIStaticMethodInContext function JMExecStaticMethodInContext instead.

You can find documentation on the Java Native Interface (JNI) at the Web page

http://java.sun.com/


JMExecJNIStaticMethodInContext

Executes a static Java method in a given AWT context thread using the Java Native Interface (JNI).

OSStatus JMExecJNIStaticMethodInContext (
                     JMAWTContextRef context,
                     JNIEnv* env,
                     jclass classID,
                     jmethodID methodID,
                     UInt32 argCount,
                     jvalue args[]);
context
The AWT context in whose thread you want the method to execute.
env
A pointer to the current JNIEnv data structure.
classID
The class ID of the class that contains the method.
methodID
The ID of the method.
argCount
The number of arguments in the args[] array, which should match the number of arguments expected by the method
args[]
The argument list.
function result
A result code; see JManager Result Codes.

DISCUSSION

Before calling this function, you must call the JMGetCurrentEnv function JMGetCurrentEnv to get the JNIEnv pointer.

For information about using this function to launch a Java application, see Executing Java Applications.

If you want to execute a nonstatic Java method, you should call the JMExecJNIMethodInContext function JMExecJNIMethodInContext instead.

You can find documentation on the Java Native Interface (JNI) at the Web page

http://java.sun.com/


JMExecMethodInContext

Executes a nonstatic Java method in a given AWT context thread using the Java Runtime Interface (JRI).

OSStatus JMExecMethodInContext (
                     JMAWTContextRef context,
                     jref objref,
                     JRIMethodID methodID,
                     UInt32 argCount,
                     JRIValue args[]);
context
The AWT context in whose thread you want the method to execute.
objref
A pointer to the Java object that contains the method you want to call.
methodID
The ID of the method.
argCount
The number of arguments in the args[] array, which should match the number of arguments expected by the method.
args[]
The argument list.
function result
A result code; see JManager Result Codes.

DISCUSSION

Unless you have a particular reason to access the Java Runtime Interface, you should instead make calls to the Java Native Interface, which provides similar functionality.

If you want to execute a static Java method (that is, one that is not local to an object) using the JRI, you must call the JMExecStaticMethodInContext function JMExecStaticMethodInContext instead.

You can find documentation on the Java Runtime Interface (JRI) at the Web page

http://developer.netscape.com/

SEE ALSO

The JMExecJNIMethodInContext function.

The JMExecJNIStaticMethodInContext function JMExecStaticMethodInContext.


JMExecStaticMethodInContext

Executes a static Java method in a given AWT context thread using the Java Runtime Interface (JRI).

OSStatus JMExecStaticMethodInContext (
                     JMAWTContextRef context,
                     JRIClassID classID,
                     JRIMethodID methodID,
                     UInt32 argCount,
                     JRIValue args[]);
context
The AWT context in whose thread you want the method to execute.
classID
The class ID of the class that contains the method.
methodID
The ID of the method.
argCount
The number of arguments in the args[] array, which should match the number of arguments expected by the method
args[]
The argument list.
function result
A result code; see JManager Result Codes.

DISCUSSION

Unless you have a particular reason to access the Java Runtime Interface, you should instead make calls to the Java Native Interface, which provides similar functionality.

If you want to execute a nonstatic Java method using the JRI, you should call the JMExecMethodInContext function JMExecMethodInContext instead.

You can find documentation on the Java Runtime Interface (JRI) at the Web page

http://developer.netscape.com/

SEE ALSO

The JMExecJNIMethodInContext function.

The JMExecJNIStaticMethodInContext function.


JMGetAwtContextJNIObject

Returns a JNI reference to a context's Java object.

jobject JMGetAwtContextJNIObject (
                     JMAWTContextRef context,
                     JNIEnv * env);
context
The context whose Java object you want to find.
env
A pointer to the current JNIEnv data structure.
function result
A pointer to the com.apple.mrj.JManager.AWTContext object associated with the frame.

DESCRIPTION

This function returns the Java equivalent of the JMAWTContextRef reference.


JMGetAwtContextObject

Returns a JRI reference to a context's Java object.

jref JMGetAwtContextObject (JMAWTContextRef context);
context
The context whose Java object you want to find.
function result
A pointer to the com.apple.mrj.JManager.AWTContext object associated with the frame.

DISCUSSION

This function returns the Java equivalent of the JMAWTContextRef reference.

Note that unless you specifically need to use the Java Runtime Interface (JRI), you should use the JMGetAwtContextJNIObject function instead.


© 1998 Apple Computer, Inc. — (Last Updated 3 Dec 98)